#pragma once

#define inherited __super

typedef unsigned short	ushort;
typedef unsigned char	byte;

typedef unsigned int	u32;
typedef unsigned short	u16;
typedef unsigned char	u8;

typedef int				i32;
typedef short			i16;
typedef char			i8;

#define SAFE_DELETE(obj)		if (obj) { delete (obj); (obj) = NULL; }
#define SAFE_DELETE_ARRAY(obj)	if (obj) { delete[] (obj); (obj) = NULL; }
#define SAFE_OGRE_DELETE(obj)	if (obj) { OGRE_DELETE obj; }

#define ASSERT(x)				assert(x)

// mem
#define	StackAlloc(T, count)	(T*)_malloca(sizeof(T*) * (count))
#define StackFree				_freea

// log
#ifdef _DEBUG
#define LOGDBG(...)				g_Log->Write(__VA_ARGS__);
#else
#define LOGDBG(...)				{}
#endif

#define LOGPRT(...)				g_Log->Write(__VA_ARGS__);

/*
template <class T>
class Ref
{
public:
	inline Ref(T* obj = NULL)							{ m_Obj = obj; SAFE_INC_REF(obj); }
	inline Ref(const Ref& other)						{ m_Obj = other.m_Obj; SAFE_INC_REF(m_Obj); }
	inline ~Ref()										{ SAFE_DEC_REF(m_Obj); }

	inline operator T* () const							{ return m_Obj; }
	inline T& operator* () const						{ return *m_Obj; }
	inline T* operator-> () const						{ return m_Obj; }

	inline Ref& operator= (const Ref& other)			{ if (m_Obj != other.m_Obj) { SAFE_INC_REF(other.m_Obj); SAFE_DEC_REF(m_Obj); m_Obj = other.m_Obj; } return *this; }
	inline Ref& operator= (T* obj)						{ if (m_Obj != obj) { SAFE_INC_REF(obj); SAFE_DEC_REF(m_Obj); m_Obj = obj; } return *this; }

	// comparisons
	inline bool operator== (T* obj) const				{ return m_Obj == obj; }
	inline bool operator!= (T* obj) const				{ return m_Obj != obj; }
	inline bool operator== (const Ref& other) const		{ return m_Obj == other.m_Obj; }
	inline bool operator!= (const Ref& other) const		{ return m_Obj != other.m_Obj; }

private:
	T* m_Obj;
};*/

#include "CoreAlgorithms.h"
#include "CoreContainers.h"
